package com.acoreful.acf2admin.commons.utils;

import org.apache.thrift.TBase;
import org.apache.thrift.TDeserializer;
import org.apache.thrift.TException;
import org.apache.thrift.TSerializer;

public class ThriftMarshaller {
	
	public static void deserialize(byte[] payload,TBase<?,?> obj) throws TException{
		TDeserializer deserializer = new TDeserializer();
		deserializer.deserialize(obj, payload);
	}
	/**
	 * 序列化
	 * @param objectToSerialize
	 * @return
	 * @throws TException
	 */
	public static byte[] serialize(TBase<?,?> objectToSerialize) throws TException{
		TSerializer serializer = new TSerializer();
		return serializer.serialize(objectToSerialize);
	}
	/*public static <T> T deserialize(Class<?> clazz,byte[] payload) throws TException{
		T t=clazz.newInstance();
		TDeserializer deserializer = new TDeserializer();
		deserializer.deserialize(t, payload);
		return t;
	}*/
}
